
package com.joolun.cloud.mall.api.controller;

import com.joolun.cloud.common.core.util.R;
import com.joolun.cloud.mall.api.annotation.ApiLogin;
import com.joolun.cloud.mall.api.service.SignRecordService;
import com.joolun.cloud.mall.api.util.ThirdSessionHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 签到记录
 *
 * @author www.joolun.com
 * @date 2021-01-13 15:29:30
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/signrecord")
@Api(value = "signrecord", tags = "签到记录API")
public class SignRecordController {

    private final SignRecordService signRecordService;

    /**
     * 签到记录查询
     * @return R
     */
    @ApiOperation(value = "签到记录查询")
    @GetMapping("/user")
	@ApiLogin
    public R getById() {
        return R.ok(signRecordService.getSignRecord(ThirdSessionHolder.getUserId()));
    }

	/**
	 * 用户签到
	 * @return R
	 */
	@ApiOperation(value = "用户签到")
	@PostMapping("/user")
	@ApiLogin
	public R userSign(){
		return R.ok(signRecordService.userSign(ThirdSessionHolder.getUserId()));
	}
}
